var e = require("../../../utils/function.js"), r = getApp(), a = require("../../../api.js");

Page({
    data: {
        imgs: e.userImg,
        img: e.driverImg,
        order: [],
        left: 0,
        isPaid: 3,
        paid: "",
        speedFee: "",
        roadToll: "",
        otherFee: "",
        order_no: "",
        is_pay: 3,
        is_status: "未支付",
        pages: 1,
        order_url: [ "/pages/driverOrder/orderedStatus/orderedStatus", "/pages/driverOrder/orderGoing/orderGoing", "/pages/driverOrder/bill/bill", "/pages/driverOrder/orderDetail/orderDetail", "/pages/driverOrder/orderedStatus/orderedStatus" ]
    },
    scrollHandler: function(e) {
        console.log("获取支付参数", e);
        e.currentTarget.dataset.pay;
        this.setData({
            isPaid: e.currentTarget.dataset.pay,
            is_pay: e.currentTarget.dataset.pay 
        }), this.data.pages = 1, this.getOrder();
    },
    intoPageHandler: function(r) {
        return 0 != this.data.order[r.currentTarget.dataset.id].apply_delete ? (wx.showToast({
            title: "订单已取消",
            icon: "none"
        }), !1) : 4 == r.currentTarget.dataset.start ? (e.intoPageHandler(r.currentTarget.dataset.skip + "?orderstart=1&order_no=" + r.currentTarget.dataset.order_no), 
        !1) : (console.log("不dengyu 4", r.currentTarget.dataset.order_no), void e.intoPageHandler(r.currentTarget.dataset.skip + "?order_no=" + r.currentTarget.dataset.order_no));
    },
    intoBill: function(e) {
        var t = e.currentTarget.dataset.order_no, s = this;
        wx.showLoading(), r.request({
            url: a.order.dept,
            method: "post",
            data: {
                order_no: t
            },
            success: function(e) {
                wx.hideLoading(), s.setData({
                    isPaid: 1,
                    is_pay: 1
                }), s.getOrder(), e.code, wx.showToast({
                    title: e.msg
                });
            }
        });
    },
    onLoad: function(e) {
        e.uid && r.shareCouponsMessage(e.uid);
    },
    onShow: function() {
        this.data.pages = 1, this.getOrder();
    },
    getOrder: function() {
        var e = this;
        wx.showLoading({}), r.request({
            url: a.order.order_status,
            method: "post",
            data: {
                is_pay: e.data.is_pay,
                p: 10
            },
            success: function(r) {
                wx.hideLoading(), e.setData({
                    order: r.data.data,
                    total: r.data.total
                });
            }
        });
    },
    cancleOrder: function(e) {
        var r = e.currentTarget.dataset.order_no;
        wx.navigateTo({
            url: "/pages/driver/deleteOrderMasker/index?order_no=" + r
        });
    },
    report: function(e) {
        var r = e.currentTarget.dataset.id;
        wx.navigateTo({
            url: "/pages/driverOrder/insuranceReport/index?id=" + r
        });
    },
    onReachBottom: function() {
        wx.showNavigationBarLoading();
        var e = this, t = this.data.pages, s = this.data.order, d = Math.ceil(this.data.total / 10);
        if (t++, t++ > d) return wx.showToast({
            title: "没有更多数据了",
            icon: "none"
        }), !1;
        r.request({
            url: a.order.order_status,
            method: "post",
            data: {
                is_pay: e.data.is_pay,
                page: t,
                p: 10
            },
            success: function(r) {
                if (0 !== r.data.data.length) for (var a = 0; a < r.data.data.length; a++) s.push(r.data.data[a]);
                e.setData({
                    order: s,
                    pages: t
                }), wx.hideNavigationBarLoading();
            }
        });
    },
    onShareAppMessage: function() {
        var e = r.shareAppMessage().title, a = r.shareAppMessage().imageUrl, t = r.shareAppMessage().desc, s = r.shareAppMessage().path;
        return console.log(r.shareAppMessage()), {
            title: e,
            imageUrl: a,
            desc: t,
            path: s
        };
    }
});